package com.baiyang.server.service.system.impl;


import com.baiyang.server.tools.DataTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baiyang.server.dao.system.RoleJurisdictionDao;
import com.baiyang.server.model.system.RoleJurisdiction;
import com.baiyang.server.service.impl.BaseServiceImpl;
import com.baiyang.server.service.system.RoleJurisdictionService;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 
 * @author XVX
 * BY: @Primary 注解帮助生命@Autowired优先注入的实列
 */
@Service	
public class RoleJurisdictionServiceImpl extends BaseServiceImpl<RoleJurisdictionDao, RoleJurisdiction>implements RoleJurisdictionService{

    @Autowired
    private RoleJurisdictionDao roleJurisdictionDao = null;

    @Override
    public void DelAndInsertBatch(List<RoleJurisdiction> roleJurisdictions, String roleId) {
        roleJurisdictionDao.deleteByRoleId(roleId);
        if(!DataTool.isBlank(roleJurisdictions)){
            roleJurisdictions.forEach(e->{
                e.setId(DataTool.createUUID());
            });
            roleJurisdictionDao.insertBatch(roleJurisdictions);
        }
    }
}
